package test03;

public class Worker {
    private String name;	//姓名
    private int age;		//年龄
    private double salary;	//工资
    public Worker() {

    }
    public Worker(String name, int age, double salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public double getSalary() {
        return salary;
    }
    public void setSalary(double salary) {
        this.salary = salary;
    }
    public void work() {
        System.out.println(name+ " 正在工作");
    }

    @Override
    public boolean equals(Object obj) {
        Worker other = (Worker) obj;
        if (age != other.age)
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        if (Double.doubleToLongBits(salary) != Double.doubleToLongBits(other.salary))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Worker [name=" + name + ", age=" + age + ", salary=" + salary
                + "]";
    }
}
